package com.myjob.config;

import com.baomidou.mybatisplus.extension.plugins.*;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author chenyuan
 * @date 2020/10/17 12:23
 */
// 开启事务管理
@EnableTransactionManagement
// 统一的管理 MyBatisPlus 配置，就把原先放在主启动类上的包扫描注解挪过来
// 扫描 Mapper 文件夹
@MapperScan("com.myjob.mapper")
@Configuration
public class MyBatisPlusConfig {
    // 注册乐观锁插件
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }

    // 分页插件
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
}
